package com.xiyun.admin.utils.excel;

import com.alibaba.excel.EasyExcel;
import com.xiyun.admin.service.DepartmentService;
import com.xiyun.admin.utils.excel.data.ReadData;
import com.xiyun.admin.utils.excel.data.WriteData;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class ExcelUtil {
    public static List<WriteData> getData(){
        List<WriteData> list = new ArrayList<>();
        WriteData data = new WriteData();
        data.setPname("中心部");
        data.setDname("研发部");
        list.add(data);
        return list;
    }
    public static void readExcel(InputStream in, DepartmentService service){
        EasyExcel.read(in,ReadData.class,new ExcelListener(service)).sheet().doRead();
    }
    public static void writeExcel(String file){
        EasyExcel.write(file,WriteData.class).sheet("部门列表").doWrite(getData());
    }
}
